package cn.bone.base.boot.demo1.dao;

import cn.bone.base.boot.demo1.bean.Person;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * Created by MD-01 on 2016/9/5.
 */
@Repository
public class PersonDao {

    @Resource(name="redisTemplate")
    private RedisTemplate<String,Person> redisTemplate;

    public void save(Person person){
        ValueOperations<String, Person> op = redisTemplate.opsForValue();
        op.set("test:person:"+person.getId(),person);
    }

    public Person get(Integer id){
        ValueOperations<String, Person> op = redisTemplate.opsForValue();
        return op.get("test:person:"+id);
    }
}
